# -*— coding: utf-8 -*-
#
# @Time : 2023/09/11 1:21
# @Author : LeeLU
# @File : connect2mysql.py
# @IDE : PyCharm
# @Email : luxuan888@vip.qq.com
# @Wechat : qianyongbuwan
# import logging

from common.readyaml import read_yaml_mysql
import pymysql


def conn_sql():
    conn = pymysql.Connect(user=read_yaml_mysql().get('user'), password=read_yaml_mysql().get('password'),
                           host=read_yaml_mysql().get('IP'), database=read_yaml_mysql().get('db'),
                           port=read_yaml_mysql().get('port'), charset=read_yaml_mysql().get('charset'))
    cursor = conn.cursor()
    # logging.info('数据库成功链接')
    # sql = 'select * from chatinfo' #sql语句
    # result = cursor.execute(sql)
    # conn.commit()
    # c = cursor.fetchall()
    # print(c)
    # # cursor.close()
    # # conn.close()
if __name__ == '__main__':
    conn_sql()